<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page session="false" %>
<%@ page isELIgnored ="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<script type="text/javascript">
//<![CDATA[
(function(){
	if(typeof Sequence === "undefined" ){
		Sequence = {
			_dlgSequenceNewId : "dialog_sequence_new",
 			_dlgSequenceEditId : "dialog_sequence_edit",
 			_dlgSequenceRemoveId : "dialog_sequence_remove",
			refresh:function(){
				dijit.byId("sequence_grid").setStore(new dojo.data.ItemFileWriteStore({url:'../../config/sequence/all.json'}));
			},
			callNew:function(){
				this.dlg = $ku.showDialog({
					id:Sequence._dlgSequenceNewId,
					url:"../../config/sequence/new.html",
					title:$ksub(KppModule.commonResource.operCreate,[SysAdmin._resource.sequence]),
					resource:SysAdmin._resource,
					style:"width:350px;height:200px;"});
			},
			callEdit:function(){
				var items = dijit.byId("sequence_grid").selection.getSelected();
				if(!items&&items.length==0){
					return;
				}
				var oid=items[0].id;
				$ku.showDialog({
					id:Sequence._dlgSequenceEditId,
					url:"../../config/sequence/update/"+oid+".html",
					title:$ksub(KppModule.commonResource.operEdit,[SysAdmin._resource.sequence]),
					resource:SysAdmin._resource,
					style:"width:350px;height:230px;"});
			},
			remove:function(oid){
				var options={
						domain:SysAdmin._resource.sequence,
						refresh:Sequence.refresh,
						url:"../../config/sequence/remove/"+oid+".json",
						button:dijit.byId("btn_sequence_remove"),
						dialogId:Sequence._dlgSequenceRemoveId,
						resource:SysAdmin._resource
				};
				KppModule.restProxy(options).remove();
			},
			callRemove:function(){
				var items = dijit.byId("sequence_grid").selection.getSelected();
				if(!items&&items.length==0){
					return;
				}
				this.dlg=dijit.byId(Sequence._dlgSequenceRemoveId);
				if(!this.dlg)this.dlg=new dijit.Dialog({
						id:Sequence._dlgSequenceRemoveId,
						title: KppModule.commonResource.confirm,
						style: "padding:0px;width:300px;height:180px;background-color:#FFF;"});
				this.dlg.set("content","<div style=\"padding:30px 20px;text-align:center\">"+$ksub(KppModule.commonResource.confirmDelete,[items[0].label])+"</div>" +
						"<div style=\"text-align:center;margin-top:10px;\"><div data-dojo-type=\"dijit.form.Button\" data-dojo-props=\"iconClass:'dijitEditorIcon dijitEditorIconDelete', id:'btn_ddType_del',showLabel:true, busyLabel:'"+KppModule.commonResource.removing+"'\">"+KppModule.commonResource.remove+
						"<script type=\"dojo/method\" event=\"onClick\" args=\"evt\">Sequence.remove('"+items[0].id+"',this)<\/script>"+
						"</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
						"<div data-dojo-type=\"dijit.form.Button\" data-dojo-props=\"iconClass:'dijitEditorIcon dijitEditorIconCancel', showLabel:true\">"+KppModule.commonResource.cancel +
						"<script type='dojo/method' event='onClick' args='evt'>dijit.byId(Sequence._dlgSequenceRemoveId).hide();<\/script></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
						"</div>"
					);
				this.dlg.show();
			},
			fmtReset:function(text){
				if(text&&text=="")return KppModule.commonResource.noRepeat;
				else return text=="d"?KppModule.commonResource.day:(text=="m"?KppModule.commonResource.month:(text=="y"?KppModule.commonResource.year:KppModule.commonResource.noRepeat));
			}
		};
		Sequence.gridStructure=[
       		{cells:[
				{field:"_item",name:KppModule.commonResource.sn,formatter:KppModule.sno,width:"30px",filterable:false},
				{field:"code",name:KppModule.commonResource.code,formatter:$kt.escapeBlank,width:"150px",datatype:"string"},
				{field:"label",name:KppModule.commonResource.label,formatter:$kt.escapeBlank,width:"200px",datatype:"string"},
				{field:"value",name:KppModule.commonResource.value,formatter:$kt.escapeBlank,width:"50px",datatype:"string"},
				{field:"lastUpdate",name:SysAdmin._resource.lastUpdate,formatter:$kt.escapeBlank,width:"150px",datatype:"string"},
				{field:"resetInterval",name:SysAdmin._resource.resetInterval,formatter:Sequence.fmtReset,width:"100px;",datatype:"string"}
       		]}
		];
	};
	$kdom.appendDojoProp("cp_sequence_nav","content","<img class=\"icon_s_admin icon_s_admin_bit\" src=\"../../../../assets/images/blank.gif\" /><span>"+SysAdmin._resource.sequence+"</span>");
	$kdom.appendDojoProp("btn_sequence_new","label",KppModule.commonResource.create);
	$kdom.appendDojoProp("btn_sequence_edit","label",KppModule.commonResource.update);
	$kdom.appendDojoProp("btn_sequence_remove","label",KppModule.commonResource.remove);
	Sequence.store = new dojo.data.ItemFileWriteStore({url:'../../config/sequence/all.json'});
})();

//]]>
</script>

<span style="display:none">To solve IE7/8 script event tag problem.</span>
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'sidebar',liveSplitters:true" class="contentWrapper" style="margin:-2px;height:100%">
	<div id="cp_sequence_nav" data-dojo-type="dijit.layout.ContentPane"  data-dojo-props="region:'top'" class="contentWrapperRight contentPaneNav" style="border:none;margin:-5px;padding:10px 0 10px 10px;background-color:transparent">
	</div>
	<div data-dojo-type="dijit/layout/ContentPane"  data-dojo-props="region:'top'" style="border:none;background-color:transparent;padding:0 4px;margin:-4px 0;">
		<div data-dojo-type="dijit/form/Button" id="btn_sequence_new" onclick="Sequence.callNew()" data-dojo-props="iconClass:'icon_s_admin icon_s_admin_bit_new'">
		</div>
		<div data-dojo-type="dijit/form/Button" id="btn_sequence_edit" onclick="Sequence.callEdit()" data-dojo-props="iconClass:'icon_s_admin icon_s_admin_bit_edit'">
		</div>
		<div data-dojo-type="dijit/form/Button" id="btn_sequence_remove" onclick="Sequence.callRemove()" data-dojo-props="iconClass:'icon_s_admin icon_s_admin_bit_remove'">
		</div>
	</div>
	<div data-dojo-type="dojox/grid/DataGrid" id="sequence_grid" class="nihilo kpp"
		data-dojo-props="structure:Sequence.gridStructure,store:Sequence.store,region:'center',canSort:function(){return false;},style:'margin:2px;'" >
	</div>
</div>